var remunit = 100;
(function (doc, win) {
  var docEl = doc.documentElement,
    resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
    recalc = function () {
      var clientWidth = docEl.clientWidth;
      if (!clientWidth) return;
      docEl.style.fontSize = (clientWidth / 19.2) + 'px';
      remunit = (clientWidth / 19.2);
    };
  // Abort if browser does not support addEventListener
  if (!doc.addEventListener) return;
  win.addEventListener(resizeEvt, recalc, false);
  doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);

function remToPx(rem){
	return rem*remunit;
}

var dynamicLoading = {
    css: function(path){
		if(!path || path.length === 0){
			throw new Error('argument "path" is required !');
		}
		var head = document.getElementsByTagName('head')[0];
        var link = document.createElement('link');
        link.href = path;
        link.rel = 'stylesheet';
        link.type = 'text/css';
        head.appendChild(link);
    },
    js: function(path){
		if(!path || path.length === 0){
			throw new Error('argument "path" is required !');
		}
        document.write("<script src='"+path+"' type='text/javascript'><\/script>");
    },
    meta: function(name,content){
		if(!name || name.length === 0){
			throw new Error('argument "name" is required !');
		}
		if(!content || content.length === 0){
			throw new Error('argument "content" is required !');
		}
		var head = document.getElementsByTagName('head')[0];
        var meta = document.createElement('meta');
        meta.name = name;
        meta.content = content;
        head.appendChild(meta);
    },
};
/*** 版本号控制 ***/
var version = "0";
var reg = new RegExp("(^|&)v=([^&]*)(&|$)");
var r = decodeURI(window.location.search).substr(1).match(reg);
if(r != null) {
	version = unescape(r[2])
}

/*****引入******/
dynamicLoading.meta("viewport","width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no");
dynamicLoading.meta("apple-mobile-web-app-capable","yes");
dynamicLoading.meta("apple-mobile-web-app-status-bar-style","black");
dynamicLoading.meta("format-detection","telephone=no");
dynamicLoading.css("mui.min.css");
dynamicLoading.js("mui.js");
dynamicLoading.js("vue.min.js");
dynamicLoading.css("font/iconfont.css?v="+version);
dynamicLoading.css("index.css?v="+version);
dynamicLoading.js("index.js?v="+version);
